<extend name="Public/base"/>

<block name="body">
	<div class="main-title">
		<h2>{$info['id']?'编辑':'新增'}表</h2>
	</div>
	<form action="{:U()}" method="post" class="form-horizontal">
	    <input type="hidden" name="dbcellindex" value="1" />
		<div class="form-item">
			<label class="item-label">表名<span class="check-tips">（只能使用英文且不能重复）</span></label>
			<div class="controls">
				<input type="text" class="text input-large" name="tname" value="{$info.tname|default='y_'}">
			</div>
		</div>
		<div class="form-item">
			<label class="item-label">别称<span class="check-tips">（用于后台显示的标题）</span></label>
			<div class="controls">
				<input type="text" class="text input-large" name="tnamec" value="{$info.tnamec|default=''}">
			</div>
		</div>

		<div class="form-item">
			<div class="data-table table-striped">
				<table id="tbdata">
					<thead>
						<tr>
							<th>列名</th>
							<th>中文名</th>
							<th>长度</th>
							<th>类型</th>
							<th>字典</th>
							<th>共享表(外键)</th>
							<th><a href="javascript:addCell()">新增一列</a></th>
						</tr>
					</thead>
					<tbody>
						<tr>
						<td>
							<input name='tname1' type='text'  class="text"/>
						</td>
						<td>
							<input name='cname1' type='text'  class="text"/>
						</td>
						<td>
							<input name='tcd1' type='text'  class="text"/>
						</td>
						<td>
							<select name='ttype1'>
		                        <option value='varchar'>文本</option>
		                        <option value='text'>富文本</option>
		                        <option value='datetime'>日期</option>
		                        <option value='int'>数字</option>
		                        <option value='bigint'>长整形</option>
		                        <option value='decimal'>数字（带小数）</option>
		                        <option value='richtext'>富文本(编辑)</option>
		                        <option value='file'>文件</option>
		                        <option value='hidden'>隐藏域</option>
		                        <option value='password'>密码框</option>
		                        <option value='image'>图片</option>
		                    </select>
						</td>
						<td>
							<select name="dict1">
								<option value=''></option>
								<notempty name="dicttable">
									<volist name="dicttable" id="dict">
										<option value="{dict.id}">{dict.name}</option>
									</volist>
								</notempty>
		                    </select>
						</td>
						<td>
							<select name="shareCell1">
								<option value=''></option>
								<notempty name="sharetable">
									<volist name="sharetable" id="share">
										<option value="{$share.vid}">{$share.vname}</option>
									</volist>
								</notempty>
		                    </select>
						</td>
						<td>
							<span>删除</span>
						</td>
						</tr>
					</tbody>
				</table>
			</div>
		</div>
		<div class="form-item">
				<button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>
				<button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
		</div>
	</form>
</block>

<block name="script">
	<script type="text/javascript">

		//导航高亮
		highlight_subnav('{:U('Config/index')}');

        var dbcellindex = 1;
        function addCell () {
                dbcellindex = dbcellindex + 1;
                $("input[name='dbcellindex']").val(dbcellindex);
                $("#tbdata tbody").append(
    				"	<tr>                                        " +
                    "       <td>                                           " +
                    "           <input name='tname" + dbcellindex + "'  class='text' type='text' />         " +
                    "       </td>                                          " +
                    "       <td>                                           " +
                    "           <input name='cname" + dbcellindex + "'  class='text' type='text' />         " +
                    "       </td>                                          " +
                    "       <td>                                           " +
                    "           <input name='tcd" + dbcellindex + "'  class='text' type='text' />           " +
                    "       </td>                                          " +
                    "       <td>                                           " +
                    "           <select name='ttype" + dbcellindex + "'>                      " +
                    "               <option value='varchar'>文本</option>  " +
                    "                <option value='text'>富文本</option>" +
                    "               <option value='datetime'>日期</option> " +
                    "               <option value='int'>数字</option>      " +
                    "               <option value='bigint'>长整形</option>      " +
                    "               <option value='decimal'>数字（带小数）</option>      " +
                    "               <option value='richtext'>富文本(编辑)</option>      " +
                    "               <option value='file'>文件</option>      " +
                    "               <option value='hidden'>隐藏域</option>      " +
                    "               <option value='password'>密码框</option>      " +
                    "               <option value='image'>图片</option>      " +
                    "           </select>                                  " +
                    "       </td>                                          " +
   					"       <td>                                                          " +
   					"       	<select name='dict" + dbcellindex + "'>                                     " +
	
						"        	</select>                                                 " +
						"       </td>                                                         " +
                 	" 		<td>                                                                   " +
       				"			<select name='shareCell" + dbcellindex + "'> <option value=''></option>          "+ 
									<notempty name='sharetable'>
										<volist name='sharetable' id='share'>
											"<option value='{$share.vid}'>{$share.vname}</option>"+
										</volist>
									</notempty>

       				"			</select>                            " +
                 	"		</td>                                                                  " +
                	"       <td>                                           " +
                	"           <a title='删除' href='javascript:void(0);' onclick='javascript:delcell(this)'>删除</a>         " +
                	"       </td>                                          " +
                	"   </tr>"
                	);
            };

        	function delcell (obj) {
                $(obj).parent().parent().remove();
                dbcellindex = dbcellindex - 1;
                $(".dbcellindex").val(dbcellindex);
            };
	</script>
</block>
